//操作类
public class MotoOperation {

	//初始化汽车,定义数组
	public Vehicle [] motos =new Vehicle[8];
	
	public void init() {
		motos[0]=new Car("宝马", "京N68879", 800, "x6");
		motos[1]=new Car("宝马", "京J87472", 600, "550i");
		motos[2]=new Car("别克", "京P6TL86", 300, "林荫大道");
		motos[3]=new Car("别克", "京HM6115", 600, "GL8");
		motos[4]=new Bus("金杯", "京M67153", 800, 16);
		motos[5]=new Bus("金杯", "京N33974", 1500, 34);
		motos[6]=new Bus("金龙", "京L68749", 800, 16);
		motos[7]=new Bus("金龙", "京K9T653", 1500, 34);
	}
	
	//租车
	public Vehicle motoLentRent(String brand, String type, int seat) {
		Vehicle moto=null;
		for(Vehicle mymoto:motos) {
			if(mymoto instanceof Car) {
				Car car=(Car) mymoto;
				if(car .getBrand().equals(brand) && car.getType().equals(type)) {
					moto=car;
					break;
				}
			}else {
				Bus bus = (Bus)mymoto;
				if(bus.getBrand().equals(brand) && bus.getSeat()==seat) {
					moto=bus;
					break;
				}
			}
		}
		return moto;
	}
	
	
	
}
